
package com.example.medicine.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

//
//@Configuration
//public class MyConfig implements WebMvcConfigurer {
//
//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        //这里是指在url上面打的内容
//        registry.addResourceHandler("/**")
//                //下面的是指可以对应resources文件下那些内容
//                .addResourceLocations("classpath:/")
//                .addResourceLocations("classpath:/templates/")
//                .addResourceLocations("classpath:/static");
//    }
//}
@Configuration
public class MyConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {   //加载拦截器
        registry.addInterceptor( new MyInterceptor () )   //加载自定义的拦截器
                .addPathPatterns("/**")     //拦截请求的路径    /** 表示所有请求
                .excludePathPatterns("/login","/loginIn","/register","/User/register","/css/*","/images/*","/js/*"); //不拦截的请求，如首页、静态资源等
    }
}
